#include <log4cplus/log4cpp.h>

// log4cplus::Logger logger = Logger::getInstance(LOG4CPLUS_TEXT( "hldlogger" ));

log4cplus::Logger logger_trace = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));
log4cplus::Logger logger_debug = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));
log4cplus::Logger logger_info = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));
log4cplus::Logger logger_warn = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));
log4cplus::Logger logger_error = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));
log4cplus::Logger logger_fatal = Logger::getInstance(LOG4CPLUS_TEXT("hldlogger"));

// 版本信息
const char *PROC_INFO = "HLD-VERSION:1.0.1 | 2025/04/30 19:50:00";

Log4cpp *Log4cpp::_instance = nullptr;
Log4cpp::Destroy Log4cpp::destroy;

Log4cpp *Log4cpp::instance()
{
    if (_instance == nullptr)
    {
        _instance = new Log4cpp();
    }
    return _instance;
}

void Log4cpp::initialize(const std::string &configFile, unsigned int watchDelayMs)
{
    try
    {
        // ConfigureAndWatchThread configureThread(LOG4CPLUS_TEXT(configFile.c_str()), watchDelayMs);
        ConfigureAndWatchThread configureThread(log4cplus::tstring(configFile.begin(), configFile.end()), watchDelayMs);

        m_initialized = true;
    }
    catch (const std::exception &ex)
    {
    }
}

bool Log4cpp::isInitialized() const
{
    return m_initialized;
}

void Log4cpp::setConfigurationItems()
{
    try
    {
        ConfigureAndWatchThread configureThread(LOG4CPLUS_TEXT("./config/log.config"), 5 * 1000);
    }
    catch (const std::exception &ex)
    {
    }
}
